/**
 * This file is part of the CAKIS project.
 * 
 * Copyright (c) 2009-2010 - Florian Arndt, Christian Kerl
 * 
 * @license GNU Lesser General Public License v3 <http://www.opensource.org/licenses/lgpl-3.0.html>
 * @since   01.03.2010
 * @version SVN: $Id: Repository.java 74 2010-04-11 17:48:11Z christian-kerl@web.de $
 */

package org.cakis.server.model.repository;

import java.io.Serializable;
import java.util.List;

/**
 * Repository provides basic methods to persist and to query the database
 * for data model entities.
 * 
 * @author Christian Kerl
 */
public interface Repository<T extends Serializable> {
    /**
     * Finds the entity with the given id.
     * 
     * @param id
     * @return The entity or null.
     */
    T findById(Long id);

    /**
     * Finds the entities in the given range.
     * 
     * @param range
     * @return
     */
    List<T> findRange(Range range);

    /**
     * Finds all entities.
     * 
     * @return
     */
    List<T> findAll();

    /**
     * Stores the given entity.
     * 
     * @param object
     * @return
     */
    T store(T object);

    /**
     * Deletes the entity with the given id.
     * 
     * @param id
     * @return
     */
    T delete(Long id);

    /**
     * Deletes the given entity.
     * 
     * @param object
     * @return
     */
    T delete(T object);
}
